Add theme helper function errors #2615
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Building on @jquense's PR (#1799), and some work done on Tailwind CSS IntelliSense, this PR adds suggestions when attempting to access unknown or invalid paths with the
themehelper function.Examples
Unknown top-level path
'colours.gray.100' does not exist in your theme config. Your theme has the following top-level keys: 'colors'Unknown object key
'colors.red' does not exist in your theme config. 'colors' has the following valid keys: 'blue', 'yellow'Unknown object key with close alternative
'colors.yellw' does not exist in your theme config. Did you mean 'colors.yellow'?Key of non-object
'colors.yellow.100' does not exist in your theme config. 'colors.yellow' is not an object.Invalid value
'colors' was found but does not resolve to a string.Object that has valid keys
'colors' was found but does not resolve to a string. Did you mean something like 'colors.yellow'?Known issues
As @jquense mentioned in their PR,
postcss-functionsdoes not expose the CSS node, so errors are thrown against the root node, which isn't mega helpful. I think the only way around this would be to forkpostcss-functions. Curious to get your thoughts on that.